package com.longcai.controller.nearby;


import com.alibaba.fastjson.JSONObject;
import com.longcai.bean.ApiResult;
import com.longcai.entity.nearby.ClyjNearbyShops;
import com.longcai.entity.nearby.ClyjNearbyShopsAdvert;
import com.longcai.service.nearby.ClyjNearbyShopsAdvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 店铺广告 前端控制器
 * </p>
 *
 * @author ZJ
 * @since 2019-03-26
 */
@Controller
@RequestMapping("/clyjNearbyShopsAdvert")
public class ClyjNearbyShopsAdvertController {
    @Autowired
    ClyjNearbyShopsAdvertService bannerService;

    /**
     * description: 附近首页广告栏展示
     * author: LWK
     * time： 10点58分
     */
    @RequestMapping("/getAdvertList")
    @ResponseBody
    public ApiResult<List<ClyjNearbyShops>> getAdvertList(@RequestBody JSONObject params) {
        ApiResult<List<ClyjNearbyShops>> result = new ApiResult<List<ClyjNearbyShops>>();
        try {
            // 标识：0：附近首页广告
            String flag = params.getString("flag");
            ClyjNearbyShopsAdvert a = new ClyjNearbyShopsAdvert();
            a.setFlag(flag);
            a.setStatus("0");
            List<ClyjNearbyShops> shopList = bannerService.getAdvertList(a);
            result.success();
            result.setData(shopList);
        } catch (Exception e) {
            e.printStackTrace();
            result.setCode("-1");
            result.fail("查询失败：" + e.getMessage());
        }
        return result;
    }
}

